package com.ay.wiki_plt.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@Slf4j
@RequestMapping("/test")
public class TestController {

    @Resource
    private RedisTemplate redisTemplate;

    @RequestMapping("/reids/set/{key}/{value}")
    public String set(@PathVariable Long key, @PathVariable String value) {
        redisTemplate.opsForValue().set(key, value, 3600, TimeUnit.SECONDS);
        log.info("key:{},value:{}", key, value);
        return "success";
    }

    @RequestMapping("/reids/get/{key}")
    public Object get(@PathVariable Long key) {
        Object value = redisTemplate.opsForValue().get(key);
        log.info("key:{},value:{}", key, value);
        return value;
    }


}
